#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDockWidget>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QDockWidget* dockwidget = new QDockWidget(this);
    this->addDockWidget(Qt::AllDockWidgetAreas,dockwidget); // 设置子窗口允许停靠的位置

    dockwidget->setWindowTitle("子窗口");
    QLabel* label = new QLabel();
    label->setText("国色天香");
    QPushButton* button = new QPushButton();
    button->setText("点我有惊喜");
//    QVBoxLayout* layout = new QVBoxLayout();
//    layout->addWidget(label);
//    layout->addWidget(button);
//    dockwidget->setWidget(label);
    // 子窗口只能有一个Widget控件
    dockwidget->setWidget(button);
}

MainWindow::~MainWindow()
{
    delete ui;
}

